package com.yangjun.controller.report;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.yangjun.service.report.DownLoadService;
import com.yangjun.service.report.ReportCommonService;
@RestController
@RequestMapping(value="/excel")
public class ReportCommonController {
	@Autowired
	private ReportCommonService reportCommonService;
	@Autowired
	private DownLoadService downLoadService;
	
	@ResponseBody
	@RequestMapping("/queryMyReport")
	public Object queryMyReport(@RequestParam(value="userid")String userid){
		return reportCommonService.queryMyReport(userid);
	}
	
	@ResponseBody
	@RequestMapping("/deleteMyReport")
	public Object deleteMyReport(@RequestParam(value="reportid")String reportid){
		return reportCommonService.deleteMyReport(reportid);
	}
	
	@ResponseBody
	@RequestMapping(value="/uploadSearchTemplet",method=RequestMethod.POST)
	public Object uploadSearchFile(@RequestParam("file") MultipartFile file,
			@RequestParam("userrealname") String userrealname,@RequestParam("userid") String userid){
		return reportCommonService.uploadSearchFile(file,userrealname,userid);
	}
	
	@RequestMapping(value="/downloadSearchTemplet",method=RequestMethod.GET)
	public void downloadTemplet(HttpServletResponse response,@RequestParam("searchName") String searchName){
		reportCommonService.downloadTemplet(response,reportCommonService.getDownloadTempletName(searchName));
	}
	
	@RequestMapping(value="/addDownloadTaskImmediately",method=RequestMethod.GET)
	public Object addDownloadTaskImmediately(@RequestParam("reportid") String reportid,HttpServletRequest request){
		return downLoadService.addDownloadTaskImmediately( reportid,request);
	}
	
}
